 $(document).ready(function(){
		   $(".top_header_wrap").load("../common/header.html")
		   $(".footer_container").load("../common/footer.html");
	   })
	   // 获取url地址后的参数
	   var url = location.href
	   var n1 = url.length
	   var n2 = url.indexOf("=")
	   var idx = decodeURI(url.substr(n2+1,n1-n2))
	   // 获取热评排行榜人民
	   var designation = document.querySelectorAll(".designation")
	   if(idx.length>1){
		   idx = 1
	   }else{
		   idx = idx
	   }
	   console.log(designation)
	   console.log(host)
	   console.log(idx)
	   // 获取学校和帖子信息
	   //获取热评
	   var app = new Vue({
		   el:"#app",
		   data:{
			   // 学校类型
			   sch_type:idx,
			   buzz:[],
			   // 学校信息
			   school_address:"",
			   school_contact:"",
			   school_icon:"",
			   school_mark:"",
			   sc_ma:"普通院校",
			   school_name:"兰州交通大学",
			   school_rank:"",
			   school_id:"",
			   // 讨论内容
			   pagebean:[],
			   // 发送帖子
			   userid : "2157eb22760a11e990ea0c96e6d7103a",
			   // 判断input框是否为空
			   hinet:true,
			   hinet_text:"输入框不能为空",
			   content_in:"" ,//input框内容
			   hintee:true,//提示数据加载
			   hintee_text:"请等待",
			   // 翻页
			   pageSize:3, //页面有多少数据
			   currPage:1, //第几页
			   // 举报
			   inform:"yi",
			   // 举报理由
			   reported:false,
			   froum_id:"",
			   userid : "",
			   // 回复
			   reply_tf : true,
			   reply_fid:"",
			   reply_sid:"",
			   reply_uid:""
		   },
		   methods:{
			   // 获取排行榜
			   getrank:function(){
			   var _this = this
				   $.ajax({
					   url:host+"discussbar/hot_coments/"+idx,
					   success:function(res){
						   console.log(res)
						   _this.buzz = res.data
					   }
				   })
			   },
		       // 获取学校信息和帖子信息
			   getmess:function(){
				   var _this = this
				   var sch_name = _this.school_name
				   var pagesize = _this.pageSize
				   var currpage = _this.currPage
				   console.log(sch_name)
				   console.log(pagesize)
				   console.log(currpage)
				   $.ajax({
					   url:host+"discussbar/forum/list/"+sch_name+"/"+pagesize+"/"+currpage+"/"+idx,
					   success:function(res){
						   console.log(res)
						   if(res.data.pageBean == null){
							   console.log(res)
							   console.log(res.data.school.school_address)
							   _this.school_address = res.data.school.school_address,
							   _this.school_contact = res.data.school.school_contact,
							   _this.school_icon = res.data.school.school_icon,
							   _this.school_name = res.data.school.school_name,
							   _this.school_rank = res.data.schoolRank,
							   _this.school_id = res.data.school.id
						   }else if(res.data.pageBean != null){
							   console.log(res)
							   _this.school_address = res.data.school.school_address,
							   _this.school_contact = res.data.school.school_contact,
							   _this.school_icon = res.data.school.school_icon,
							   _this.school_name = res.data.school.school_name,
							   _this.school_rank = res.data.schoolRank,
							   _this.school_id = res.data.school.id
							   _this.pagebean = res.data.pageBean.list
							   _this.forumid = res.data.pageBean.list
						   }
						   console.log(_this.school_name)
						   console.log(_this.school_rank)
						   console.log(_this.pagebean)
					   }
				   })
			   },
		       // 发送帖子
			   trans:function(){
				   var _this = this
				   var schoolid = _this.school_id
				   var userid = _this.userid
				   var content = $("#inp_con").val()
				  console.log("输入内容："+$("#inp_con").val())
				  console.log("用户id："+userid)
				  console.log("学校id："+schoolid)
				  console.log("学校类型："+idx)
				  if(content.length == 0){
					  _this.hinet = false
					  setTimeout(function(){
						  _this.hinet=true
						  _this.hinet_text=""
					  },2000)
				  }else if(content.length != 0){
					  _this.hinet = true;
					   _this.$http.post(
						 host+"discussbar/add",
						 {
							 userId:userid,
							 schoolId:schoolid,
							 content:content,
							 discussbarType:idx
						 },
						 {emulateJSON: true}
					   ).then((res)=>{
						   console.log(res)
						   if(res.body.data == "发布消息成功" && res.body.status == 0){
							   _this.hinet = false
								_this.hinet_text = "发布成功"
								   _this.content_in = ""
							   setTimeout(function(){
								   _this.hinet = true
							   },2000)
								 _this.seem()
						   }else{
							   _this.hinet = false
								_this.hinet_text = "网络异常"
								   _this.content_in = ""
							   setTimeout(function(){
								   _this.hinet = true
							   },2000)
						   }
					   })
					  }
			  },
		       // 查看更多
			   seem:function(){
				   var _this = this
				   var pagebe = _this.pagebean    //数组列表
				   var pagesize = _this.pageSize  //显示可视数据
				   var currpage = _this.currPage  //页数
				   var school_name = _this.school_name //学校名称
				   console.log(pagebe)
				   console.log(pagesize)
				   console.log(currpage)
				   console.log(school_name)
				   pagesize += 3
				   console.log(_this.pageSize)
				   console.log(_this.pagebean)
				   axios.get(host+"discussbar/forum/list/"+school_name+"/"+pagesize+"/"+currpage+"/"+idx).then((res)=>{
					    var pagel = res.data.data.pageBean.list
						var pageh = res.data.data.pageBean
						console.log(pagebe)
						console.log(pageh)
						console.log(pagel.length)
						_this.pagebean = pagel
						if(pagel.length == pageh.totalCount){
							_this.hintee = false
							setTimeout(function(){
								_this.hintee = true
								_this.hintee_text = "无更多内容"
							},2000)
						}
				   })
				    _this.pageSize = pagesize
				   console.log(_this.pagebean)
				   console.log(_this.pageSize)
			   },
		       // 点击出现举报
			   report:function(index,event,fid,userid){
				   console.log(index)
				   console.log(event)
				   console.log(fid)
				   console.log(userid)
				   var _this = this
				   _this.inform = index
				   _this.froum_id = fid
				   _this.userid = userid
				   setTimeout(function(){
					   _this.inform = "yi"
				   },3000)
			   },
			   // 打开举报信息
			   open:function(){
				   var _this = this
				   _this.reported = true
			   },
			   // 关闭举报信息
			   close:function(){
				   var _this = this
					_this.reported = false
			   },
			   // 调取举报接口
			   whistle:function(event){
				   var _this = this
				   var fid = _this.froum_id
				   var uid = _this.userid
				   var infor_type = event.target.dataset.rep
				   console.log("评论id："+fid)
				   console.log("用户id："+uid)
				   console.log("举报类型："+infor_type)
				   console.log("学校类型："+idx)
				   console.log("url地址："+host)
				   axios.get(host+"discussbar/Report/"+fid+"/"+infor_type+"/"+uid+"/"+idx).then((res)=>{
					   console.log(res)
					   if(res.data.data == "举报失败"){
						   alert("网络异常")
						   _this.reported = false
					   }else if(res.data.data == "举报成功"){
						   alert("举报成功")
						   _this.reported = false
					   }
				   })
			   },
			   // 点赞
			   give_like:function(fid){
				   // /thumbsup/{froumid}/{discussbar_type}
				   // /discussbar/thumbsup/092efe9e778511e984a40c96e6d7103a/1
				   var _this = this
				   console.log(1)
				   console.log(fid)
				   axios.get(host+"discussbar/thumbsup/"+fid+"/"+idx).then((res)=>{
					   console.log(res)
					   if(res.data.status == 0){
						   _this.getmess()
					   }else if(res.data.status != 0 ){
						   alert("网络异常")
					   }
				   })
			   },
			   // 查看更多子评论
			   look_more:function(fid){
				   // url + idx + school_name
				   var _this = this
				   var idx = _this.sch_type
				   console.log(idx)
				   var school_name =encodeURIComponent(_this.school_name)
				   console.log(school_name)
				   window.location.href = "http://127.0.0.1:8848/hailongkeji/view/discuss_zone/report.html?idx="+idx+"&sch_name="+school_name+"&fid="+fid
			   },
			   // 回复
			   // /reply/{forum_id}/{forum_content}/{school_id}/{userId}/{discussbar_type}
			   active:function(fid,sch_id,uid){
				   var _this = this
				   _this.reply_tf = false
				   _this.reply_fid = fid
				   _this.reply_sid = sch_id
				   _this.reply_uid = uid
				   console.log("学校类型："+idx)
				   console.log("学校id："+sch_id)
				   console.log("用户id："+uid)
				   console.log("评论id："+fid)
			   },
			   // 提交回复
			  //  reply_sum:function(){
				 // var _this = this
				 // var uid = _this.reply_uid
				 // var fid = _this.reply_fid
				 // var sid = _this.reply_sid
				 // var re_con = $("#repl").val()
				 //   console.log("学校类型："+idx)
				 //   console.log("学校id："+sid)
				 //   console.log("用户id："+uid)
				 //   console.log("评论id："+fid)
				 //   console.log("评论内容："+re_con)
				 // // axios.post(host+"discussbar/reply",{forum_id:fid,forum_content:re_con,school_id:sid,userId:uid,discussbar_type:idx},{emulateJSON: true}).then((res)=>{
					// //  console.log(res)
				 // // })
				 //  _this.$http.post(host+"discussbar/reply",
				 //  {
				 // 	forum_id:fid,
					// forum_content:re_con,
					// school_id:sid,
					// userId:uid,
					// discussbar_type:idx
				 //  },
				 // 	{emulateJSON: true},
				 // ).then((res)=>{
					//  console.log(res)
				 // })
			  //  },
			   cloose:function(){
				   var _this = this
				   _this.reply_tf = true
			   },
		       // 搜索
			   seach:function(){
				   
				   axios.get(host+"discussbar/forum/list/{school_name}/{page_size}/{page_number}/{discussbar_type}")
			   },
		   },
		   created:function() {
			   var _this = this
		   	  _this.getrank() //排行榜
			  _this.getmess() //获取信息
		   }
	   })
	   
	   console.log(app)
	   console.log(idx)
	   console.log(app.reply_tf)
	   console.log(app.reply_fid)
	   console.log(app.reply_sid)
	   console.log(app.reply_uid)
		$(".btn").on("click",function(){
		   console.log(app)
		   console.log(idx)
		   console.log(app.reply_tf)
		   console.log("回复id:"+app.reply_fid)
		   console.log("学校id："+app.reply_sid)
		   console.log("用户id："+app.reply_uid)
		   console.log(host)
		   console.log("用户回复："+$("#repl").val())
		   var re_con = $("#repl").val()
		   var fid = app.reply_fid
		   var sid = app.reply_sid
		   var uid = app.reply_uid
		   $.ajax({
			   type:"post",
			   url:host+"discussbar/reply",
			   dataType:"JSON",
			   contentType: "application/json;charset=utf-8",
			   xhrFields: {
						withCredentials: true
			    },
			    crossDomain: true,
			   data:{
				   forum_id:fid,
				   forum_content:re_con,
				   school_id:sid,
				   userId:uid,
				   discussbar_type:idx
			   },
			   success:function(res){
				   console.log(res)
			   }
		   })
		})
// 	   $.ajax({
// 				type: "post",
// 				url: "http://47.111.188.27:8080/gsgkzyl/user/login",
// 				xhrFields: {
// 					withCredentials: true
// 				},
// 				crossDomain: true,
// 				//contentType: "application/x-www-form-urlencoded; charset=UTF-8",
// 				data: {
// 					mobile: phone,
// 					password: password,
// 				},
// 				success: function(log) {
// 					console.log(log)
// 					if(log.status == 0) {
// 			
// 							window.location.href = "dynamic/news.html";
// 					
// 						
// 					} else {
// 						$('#msg').show();
// 						$('#msg').html(log.msg);
// 
// 					}
// 				}
// 			});